# -*- coding: utf-8 -*-
# @File  : app01.py
# @Author:  liubinyu
# @Time: 2024/5/19 11:39
from typing import Union, Optional

from fastapi import APIRouter

app01 = APIRouter()

# 路径参数 user_id 的值将作为参数 user_id 传递给你的函数。
# user_id 被声明为 int 类型。
@app01.get("/user/{user_id}")
async def get_user(user_id: int):
    # print(user_id, type(user_id))
    return {"user_id": user_id}


@app01.get("/user/me")
async def read_user_me():
    return {"username": "the current user"}

@app01.get("/user/{username}")
async def read_user(username: str):
    return {"username": username}
